package com.example.shop.modules.manage.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.shop.modules.manage.service.IGoodsTypeAdminService;
import com.example.shop.persistence.entity.GoodsType;
import com.example.shop.persistence.mapper.GoodsTypeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 商品分类表 服务实现类
 * </p>
 *
 * @author jason
 * @since 2019-12-16
 */
@Service
public class GoodsTypeAdminServiceImpl extends ServiceImpl<GoodsTypeMapper, GoodsType> implements IGoodsTypeAdminService {
    @Autowired
    private GoodsTypeMapper goodsTypeMapper;
    /*
    public int insertGoodsType(GoodsType goodsType){
        return goodsTypeMapper.insert(goodsType);
    }
    public int updateGoodsType(GoodsType goodsType){
        return goodsTypeMapper.updateByPrimaryKey(goodsType);
    }
    */
    public int deleteGoodsType(Integer id){
        QueryWrapper ew = new QueryWrapper();
        ew.eq("id",id);
        ew.or();
        // 连同下级分类一起删除
        ew.eq("parentID",id);
        return goodsTypeMapper.delete(ew);
    }


}
